// 获取操作对象
var submit1 = document.querySelector('[type="submit"]');
var inp1 = document.querySelector('[name="user1"]');
var inp2 = document.querySelector('[name="pass1"]');
var frm = document.querySelector("form");
// 获取地址栏中的参数
// console.log(location);
var search1 = location.search;
// 给当前的form表单绑定提交事件;
frm.onsubmit = function () {
  console.log(1);
  var user1 = inp1.value;
  var pass1 = inp2.value;
  (async function () {
    // 接收返回的值
    var p1 = await PromiseAjax({
      url: "../php/register.php",
      data: `username=${user1}&password=${pass1}`,
    });
    console.log(p1);
    // 根据返回的响应结果，判断登录是否成功
    if (p1 == 1) {
      alert("注册成功，请重新登录");
      location = "./login.html";
    } else {
      alert("不正确，请重新注册");
    }
  })();
  // 阻止默认行为
  return false;
};
